using System;

namespace csammisrun.OscarLib.Utility
{
	/// <summary>
	/// Provides static methods for processing messages in SNAC family 0x0006 -- invitation service
	/// </summary>
	internal static class SNAC06
	{
    /// <summary>
		/// Sends an AIM invitation to a receipient -- SNAC(06,02)
		/// </summary>
		/// <param name="sess">A <see cref="Session"/> object</param>
		/// <param name="email">The email address of the person to invite</param>
		/// <param name="text">The text of the invitation</param>
		public static void SendInvitiationRequest(Session sess, string email, string text)
		{
			SNACHeader sh = new SNACHeader();
			sh.FamilyServiceID = (ushort)SNACFamily.PrivacyManagementService;
			sh.FamilySubtypeID = (ushort)PrivacyManagementService.ServiceParametersRequest;
			sh.Flags = 0x0000;
			sh.RequestID = sess.GetNextRequestID();

			TLV[] tlvs = new TLV[2];
      tlvs[0] = TLVMarshal.MakeTLV(0x0011, Marshal.StringToByteArray(email, Marshal.ASCII));
      tlvs[1] = TLVMarshal.MakeTLV(0x0015, Marshal.StringToByteArray(text, Marshal.ASCII));

			DataPacket dp = Marshal.BuildDataPacket(sess, sh, TLVMarshal.TLVsToByteArray(tlvs));
			SNACFunctions.BuildFLAP(dp);
		}

		/// <summary>
		/// Processes the parameter information sent by the server -- SNAC(06,03)
		/// </summary>
		/// <param name="dp">A <see cref="DataPacket"/> object with a buffer containing SNAC(06,03) </param>
		public static void ProcessInvitationConfirmation(DataPacket dp)
		{
			byte[] SNACData = dp.Data;

			// ...and that's it. Perhaps a user callback?
		}
	}
}
